Skip to content

fix(error_reporting): respect quota_project configuration#34610

Merged
torreypayne merged 1 commit into
mainfrom
fix-error-reporting-quota-project
Jun 16, 2026
Merged

fix(error_reporting): respect quota_project configuration#34610
torreypayne merged 1 commit into
mainfrom
fix-error-reporting-quota-project

Conversation

@torreypayne

@torreypayne torreypayne commented Jun 11, 2026

Copy link
Copy Markdown
Member

fix(error_reporting): respect quota_project configuration

This PR fixes an issue where the Google::Cloud::ErrorReporting client was completely ignoring the quota_project configuration parameter, causing API calls to default billing to the project associated with the credentials. This resulted in PermissionDeniedError (Error Reporting API not enabled) for users attempting to report errors to a target project that was different from their credentials project (e.g., issue #25862).

closes: #25862

Changes

  • Respect Configuration: Updated Google::Cloud::ErrorReporting.new to correctly resolve quota_project from the library configuration and pipe it down to the internal Service layer.
  • Service Wrapper: Updated Google::Cloud::ErrorReporting::Service to accept quota_project (falling back to credentials) and apply it to the underlying gRPC client configuration.
  • Documentation: Added multi-project configuration examples and descriptions to README.md and AUTHENTICATION.md.
  • Testing: Added unit test coverage to confirm configuration propagation and refined YARD doctest mock expectations.
  • Modernization: Modernized Google::Cloud::ErrorReporting::Project#report to use Ruby 3.2+ anonymous block forwarding (*args, &), resolving pre-existing RuboCop style offenses.

Expectation Setting: Target Project vs. Quota Project

In Google Cloud APIs, the Target Project (where resources are stored/written) and the Quota Project (which project is billed for the API call) are intentionally separate concepts:

  • By default, the library bills the project associated with your credentials.
  • If you need to report errors to a project that differs from your credentials project, you must explicitly configure quota_project via library configuration or the GOOGLE_CLOUD_QUOTA_PROJECT environment variable.

Configuration Example:

Google::Cloud::ErrorReporting.configure do |config|
  config.project_id    = "target-project-id"   # Where error events are ingested
  config.quota_project = "billing-project-id"  # Project billed for the quota
  config.credentials   = "path/to/keyfile.json"
end

# Client will now respect the configured quota project for billing
client = Google::Cloud::ErrorReporting.new

@torreypayne torreypayne marked this pull request as ready for review June 12, 2026 20:13
@torreypayne torreypayne requested review from a team and yoshi-approver as code owners June 12, 2026 20:13
@torreypayne torreypayne changed the title fix: support quota_project in ErrorReporting client fix(error_reporting): respect quota_project configuration Jun 15, 2026

@aandreassa aandreassa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! A couple nits

Comment thread google-cloud-error_reporting/lib/google/cloud/error_reporting.rb Outdated
Comment thread google-cloud-error_reporting/lib/google/cloud/error_reporting/service.rb Outdated
Comment thread google-cloud-error_reporting/support/doctest_helper.rb Outdated
Comment thread google-cloud-error_reporting/test/google/cloud/error_reporting_test.rb Outdated
@torreypayne torreypayne requested a review from aandreassa June 16, 2026 16:22

@aandreassa aandreassa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TY!

This PR fixes an issue where the `Google::Cloud::ErrorReporting` client was completely ignoring the `quota_project` configuration parameter, causing API calls to default billing to the project associated with the credentials. This resulted in `PermissionDeniedError` (Error Reporting API not enabled) for users attempting to report errors to a target project that was different from their credentials project (e.g., issue #25862).

### Changes
*   Respect Configuration: Updated `Google::Cloud::ErrorReporting.new` to correctly resolve `quota_project` from the library configuration and pipe it down to the internal `Service` layer.
*   Service Wrapper: Updated `Google::Cloud::ErrorReporting::Service` to accept `quota_project` (falling back to credentials) and apply it to the underlying gRPC client configuration.
*   Documentation: Added multi-project configuration examples and descriptions to `README.md` and `AUTHENTICATION.md`.
*   Testing: Added unit test coverage to confirm configuration propagation and refined YARD doctest mock expectations.
*   Modernization: Modernized `Google::Cloud::ErrorReporting::Project#report` to use Ruby 3.2+ anonymous block forwarding (`*args, &`), resolving pre-existing RuboCop style offenses.
*   Monorepo Style: Resolved `Lint/SafeNavigationWithEmpty` in top-level `.toys/ci.rb` to ensure modern Ruby CI workflows pass cleanly.

TAG=agy
CONV=8c6d3acb-f6a5-49ce-8263-7c87d2430e6f
@torreypayne torreypayne force-pushed the fix-error-reporting-quota-project branch from feb4413 to 314648c Compare June 16, 2026 19:58
@torreypayne torreypayne merged commit eeed499 into main Jun 16, 2026
19 checks passed
@torreypayne torreypayne deleted the fix-error-reporting-quota-project branch June 16, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The project_id option of Google::Cloud::ErrorReporting.new does not work

3 participants